package com.xuzhen.reflect;

import java.lang.reflect.*;

public class Method1 {
   private int f1(Object p, int x) throws NullPointerException
   {
      if (p == null)
         throw new NullPointerException();
      return x;
   }
   
   public void add(int a,int b){
	   
   }
     
   public static void main(String args[])
   {
      try {
        Class cls = Class.forName("com.xuzhen.reflect.Method1");
     
         Method methlist[] = cls.getMethods();
         for (int i = 0; i < methlist.length; i++) {  
            Method m = methlist[i];
            System.out.println("name = " + m.getName());
            System.out.println("decl class = " +m.getDeclaringClass());
            Class pvec[] = m.getParameterTypes();
            for (int j = 0; j < pvec.length; j++)
               System.out.println("param #" + j + " " + pvec[j]);
            Class evec[] = m.getExceptionTypes();
            for (int j = 0; j < evec.length; j++)
               System.out.println("exc #" + j  + " " + evec[j]);
            System.out.println("return type = " + m.getReturnType());
            System.out.println("-----");
         }
         System.out.println("--------------------------");
         Method m = cls.getDeclaredMethod("f1", Object.class,Integer.TYPE);
         System.out.println("name = " + m.getName());
         System.out.println("decl class = " +m.getDeclaringClass());
         Class pvec[] = m.getParameterTypes();
         for (int j = 0; j < pvec.length; j++)
            System.out.println("param #" + j + " " + pvec[j]);
         Class evec[] = m.getExceptionTypes();
         for (int j = 0; j < evec.length; j++)
            System.out.println("exc #" + j  + " " + evec[j]);
         System.out.println("return type = " + m.getReturnType());
         System.out.println("-----");
      }
      catch (Throwable e) {
    	 e.printStackTrace();
         System.err.println(e);
      }
   }
}